//package com.example.soapclient.controller;
//
//import com.example.soapclient.service.SoapClientService;
//import com.example.soapclient.model.CreateUserResponse;
//import com.example.soapclient.model.GetAllUsersResponse;
//import com.example.soapclient.model.GetUserResponse;
//import org.springframework.http.ResponseEntity;
//import org.springframework.web.bind.annotation.*;
//
//@RestController
//@RequestMapping("/api/users")
//public class UserController {
//
//    private final SoapClientService soapClientService;
//
//    public UserController(SoapClientService soapClientService) {
//        this.soapClientService = soapClientService;
//    }
//
//    @GetMapping("/{id}")
//    public ResponseEntity<GetUserResponse> getUserById(@PathVariable long id) {
//        try {
//            GetUserResponse response = soapClientService.getUserById(id);
//            return ResponseEntity.ok(response);
//        } catch (Exception e) {
//            return ResponseEntity.badRequest().body(null);
//        }
//    }
//
//    @GetMapping
//    public ResponseEntity<GetAllUsersResponse> getAllUsers() {
//        try {
//            GetAllUsersResponse response = soapClientService.getAllUsers();
//            return ResponseEntity.ok(response);
//        } catch (Exception e) {
//            return ResponseEntity.badRequest().body(null);
//        }
//    }
//
//    @PostMapping
//    public ResponseEntity<CreateUserResponse> createUser(
//            @RequestParam String name,
//            @RequestParam String email,
//            @RequestParam(required = false) Integer age) {
//        try {
//            CreateUserResponse response = soapClientService.createUser(name, email, age);
//            return ResponseEntity.ok(response);
//        } catch (Exception e) {
//            return ResponseEntity.badRequest().body(null);
//        }
//    }
//
//    @GetMapping("/{id}/xml")
//    public ResponseEntity<String> getUserAsXml(@PathVariable long id) {
//        try {
//            String xmlResponse = soapClientService.getRawSoapResponse(id);
//            return ResponseEntity.ok()
//                    .header("Content-Type", "application/xml")
//                    .body(xmlResponse);
//        } catch (Exception e) {
//            return ResponseEntity.badRequest().body("Error: " + e.getMessage());
//        }
//    }
//}